* Created using Stata 14 (for Windows and Linux)
clear all
set more off
cd "I:\coercive_and_catalytic_replication"
use "analysis.dta"

set more off

*******************************************
* PREPARE DATA FOR MARGINAL EFFECTS PLOTS *
*******************************************
set scheme plotplainblind

summarize repression_L1_demeaned
return list
global repress_hi=round(r(mean)+r(sd),0.1)
global repress_avg=round(r(mean),0.1)
global repress_lo=round(r(mean)-r(sd),0.1)

summarize idealptdist_L1_demeaned
return list
global idealpt_hi=round(r(mean)+r(sd),0.1)
global idealpt_avg=round(r(mean),0.1)
global idealpt_lo=round(r(mean)-r(sd),0.1)

summarize donorrights_L1_demeaned
return list
global drights_hi=round(r(mean)+r(sd),0.1)
global drights_avg=round(r(mean),0.1)
global drights_lo=round(r(mean)-r(sd),0.1)

summarize xdem_L1_demeaned
return list
global xdem_hi=round(r(mean)+r(sd),0.1)
global xdem_avg=round(r(mean),0.1)
global xdem_lo=round(r(mean)-r(sd),0.1)

summarize statecap_L1_demeaned
return list
global statecap_hi=round(r(mean)+r(sd),0.1)
global statecap_avg=round(r(mean),0.1)
global statecap_lo=round(r(mean)-r(sd),0.1)

summarize lnexport_L1_demeaned
return list
global lnexp_hi=round(r(mean)+r(sd),0.1)
global lnexp_avg=round(r(mean),0.1)
global lnexp_lo=round(r(mean)-r(sd),0.1)

summarize shame_physint_L1_demeaned
return list
global shame_hi=round(r(mean)+r(sd),0.1)
global shame_avg=round(r(mean),0.1)
global shame_lo=round(r(mean)-r(sd),0.1)

summarize ln_terror_events_L1_demeaned
return list
global terror_hi=round(r(mean)+r(sd),0.1)
global terror_avg=round(r(mean),0.1)
global terror_lo=round(r(mean)-r(sd),0.1)

set more off
xtset dyad_id year

**************************************************
* TOBIT MODELS FOR ECONOMIC AID DV               *
**************************************************

* Model 1: Economic Aid Base (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode, ll(0) cl(donorcode)
est sto m1_econ_base
margins, at(repression_L1_demeaned=(-4(.5)4))
marginsplot
graph save Graph "graphs\1_econ_base.gph", replace

* Model 2: Econ Donor Rights (Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year c.donorrights_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m2_econ_donorrights

margins, dydx(repression_L1_demeaned) at(donorrights_L1_demeaned=(-4(2)4))
margins, at(repression_L1_demeaned=(-4(1)4) donorrights_L1_demeaned=($drights_lo $drights_avg $drights_hi))
marginsplot, legend(position(6))
* Figure 3(a) Donor Rights
graph save Graph "graphs\2_econ_donorrights.gph", replace

* Model 3: Econ Ideal Point (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.idealptdist_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m3_econ_idealpt

margins, dydx(repression_L1_demeaned) at(idealptdist_L1_demeaned=(-1.5(2)3))
margins, dydx(repression_L1_demeaned) at(idealptdist_L1_demeaned=($idealpt_lo $idealpt_avg $idealpt_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) idealptdist_L1_demeaned=($idealpt_lo $idealpt_avg $idealpt_hi))
marginsplot, legend(position(6))
* Figure 3(b) Ideal Point Distance
graph save Graph "graphs\3_econ_idealpt.gph", replace

* Model 4: Econ Export (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.lnexport_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m4_econ_lnexport

margins, dydx(repression_L1_demeaned) at(lnexport_L1_demeaned=(-14(6)10))
margins, dydx(repression_L1_demeaned) at(lnexport_L1_demeaned=($lnexp_lo $lnexp_avg $lnexp_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) lnexport_L1_demeaned=($lnexp_lo $lnexp_avg $lnexp_hi))
marginsplot, legend(position(6))
* Figure 3(c) Exports
graph save Graph "graphs\4_econ_lnexport.gph", replace

* Model 5: Econ Executive Constraints (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.xdem_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m5_econ_execconst

margins, dydx(repression_L1_demeaned) at(xdem_L1_demeaned=(-1(1)1))
margins, dydx(repression_L1_demeaned) at(xdem_L1_demeaned=($xdem_lo $xdem_avg $xdem_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) xdem_L1_demeaned=($xdem_lo $xdem_avg $xdem_hi))
marginsplot, legend(position(6))
* Figure 4(a) Executive constraints
graph save Graph "graphs\5_econ_execconst.gph", replace

* Model 6: Econ State Capacity (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.statecap_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m6_econ_statecap

margins, dydx(repression_L1_demeaned) at(statecap_L1_demeaned=(-2(1)2))
margins, dydx(repression_L1_demeaned) at(statecap_L1_demeaned=($statecap_lo $statecap_avg $statecap_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) statecap_L1_demeaned=($statecap_lo $statecap_avg $statecap_hi))
marginsplot, legend(position(6))
* Figure 4(b) State capacity
graph save Graph "graphs\6_econ_statecap.gph", replace

* Model 7: Econ Terrorism (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.ln_terror_events_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m7_econ_terror

margins, dydx(repression_L1_demeaned) at(ln_terror_events_L1_demeaned=(-1(1)7))
margins, dydx(repression_L1_demeaned) at(ln_terror_events_L1_demeaned=($terror_lo $terror_avg $terror_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) ln_terror_events_L1_demeaned=($terror_lo $terror_avg $terror_hi))
marginsplot, legend(position(6))
* Figure 4(c) Terrorism
graph save Graph "graphs\7_econ_terror.gph", replace

* Model 8: Econ Shaming (Donor-Year FE) 
tobit lneconaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode shame_physint_L1_demeaned c.shame_physint_L1_demeaned#c.repression_L1_demeaned , ll(0) cl(donorcode)
est sto m8_econ_shaming

margins, dydx(repression_L1_demeaned) at(shame_physint_L1_demeaned=(-.25(.25)1))
margins, dydx(repression_L1_demeaned) at(shame_physint_L1_demeaned=($shame_lo $shame_avg $shame_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) shame_physint_L1_demeaned=($shame_lo $shame_avg $shame_hi))
marginsplot, legend(position(6))
* Figure 3(d) Shaming
graph save Graph "graphs\8_econ_shaming.gph", replace

***********************************
* TABLE: TOBIT ECONOMIC SECTOR DV *
***********************************
global econtobit m1_econ_base m2_econ_donorrights m3_econ_idealpt m4_econ_lnexport m5_econ_execconst m6_econ_statecap m7_econ_terror m8_econ_shaming
* Table 2: Economic Aid Dependent Variable
outreg2 [${econtobit}] using "econ_table_2fe.xls", label replace excel

* Model 9: Governance Aid Base (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode, ll(0) cl(donorcode)
est sto m9_gov_base
margins, at(repression_L1_demeaned=(-4(.5)4))
marginsplot
graph save Graph "graphs\9_gov_base.gph", replace


* Model 10: Governance Donor Rights (Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year c.donorrights_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m10_gov_donorrights

margins, dydx(repression_L1_demeaned) at(donorrights_L1_demeaned=(-4(2)4))
margins, at(repression_L1_demeaned=(-4(1)4) donorrights_L1_demeaned=($drights_lo $drights_avg $drights_hi))
marginsplot, legend(position(6))
* Figure 5(a) Donor rights
graph save Graph "graphs\10_gov_donorrights.gph", replace

* Model 11: Governance Ideal Point (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.idealptdist_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m11_gov_idealpt

margins, dydx(repression_L1_demeaned) at(idealptdist_L1_demeaned=(-1.5(2)3))
margins, dydx(repression_L1_demeaned) at(idealptdist_L1_demeaned=($idealpt_lo $idealpt_avg $idealpt_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) idealptdist_L1_demeaned=($idealpt_lo $idealpt_avg $idealpt_hi))
marginsplot, legend(position(6))
* Figure 5(b) Ideal point distance
graph save Graph "graphs\11_gov_idealpt.gph", replace

* Model 12: Governance Export (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.lnexport_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m12_gov_lnexport

margins, dydx(repression_L1_demeaned) at(lnexport_L1_demeaned=(-14(6)10))
margins, dydx(repression_L1_demeaned) at(lnexport_L1_demeaned=($lnexp_lo $lnexp_avg $lnexp_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) lnexport_L1_demeaned=($lnexp_lo $lnexp_avg $lnexp_hi))
marginsplot, legend(position(6))
* Figure 5(c) Exports
graph save Graph "graphs\12_gov_lnexport.gph", replace

* Model 13: Governance Executive Constraints (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.xdem_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m13_gov_execconst

margins, dydx(repression_L1_demeaned) at(xdem_L1_demeaned=(-1(1)1))
margins, dydx(repression_L1_demeaned) at(xdem_L1_demeaned=($xdem_lo $xdem_avg $xdem_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) xdem_L1_demeaned=($xdem_lo $xdem_avg $xdem_hi))
marginsplot, legend(position(6))
* Figure 7(a) Executive constraints
graph save Graph "graphs\13_gov_execconst.gph", replace

* Model 14: Governance State Capacity (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.statecap_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m14_gov_statecap

margins, dydx(repression_L1_demeaned) at(statecap_L1_demeaned=(-2(1)2))
margins, dydx(repression_L1_demeaned) at(statecap_L1_demeaned=($statecap_lo $statecap_avg $statecap_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) statecap_L1_demeaned=($statecap_lo $statecap_avg $statecap_hi))
marginsplot, legend(position(6))
* Figure 7(b) State capacity
graph save Graph "graphs\14_gov_statecap.gph", replace

* Model 15: Governance Terrorism (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode c.ln_terror_events_L1_demeaned#c.repression_L1_demeaned, ll(0) cl(donorcode)
est sto m15_gov_terror

margins, dydx(repression_L1_demeaned) at(ln_terror_events_L1_demeaned=(-1(1)7))
margins, dydx(repression_L1_demeaned) at(ln_terror_events_L1_demeaned=($terror_lo $terror_avg $terror_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) ln_terror_events_L1_demeaned=($terror_lo $terror_avg $terror_hi))
marginsplot, legend(position(6))
* Figure 7(c) Terrorism 
graph save Graph "graphs\15_gov_terror.gph", replace

* Model 16: Governance Shaming (Donor-Year FE) 
tobit lngovaidpc repression_L1_demeaned donorrights_L1_demeaned idealptdist_L1_demeaned lnexport_L1_demeaned xdem_L1_demeaned statecap_L1_demeaned ln_terror_events_L1_demeaned 1.highdissent_L1 lngdp_L1_demeaned lnpop_L1_demeaned conflict_L1 hhi_recip_L1_demeaned statist_donor i.year i.donorcode shame_physint_L1_demeaned c.shame_physint_L1_demeaned#c.repression_L1_demeaned , ll(0) cl(donorcode)
est sto m16_gov_shaming

margins, dydx(repression_L1_demeaned) at(shame_physint_L1_demeaned=(-.25(.25)1))
margins, dydx(repression_L1_demeaned) at(shame_physint_L1_demeaned=($shame_lo $shame_avg $shame_hi)) pwcompare(effects)
margins, at(repression_L1_demeaned=(-4(1)4) shame_physint_L1_demeaned=($shame_lo $shame_avg $shame_hi))
marginsplot, legend(position(6))
*Figure 6(d) Shaming
graph save Graph "graphs\16_gov_shaming.gph", replace


****************************************************
* TABLE: RANDOM EFFECTS TOBIT GOVERNANCE SECTOR DV *
****************************************************

global govtobit m9_gov_base m10_gov_donorrights m11_gov_idealpt m12_gov_lnexport m13_gov_execconst m14_gov_statecap m15_gov_terror m16_gov_shaming
* Table 3: Governance aid dependent variable
outreg2 [${govtobit}] using "gov_table_2fe.xls", label replace excel




